<?php
/**
 * Hosting Menu
 * @author Tomas Srna
 * @package bakalarka
 */

class HostingMenu extends Menu
{
	protected $_children = array();
	protected $_action = 'hosting';
	
	public function __construct($action = 'hosting')
	{
		$this->_action = $action;
		
		$hostings = Selector::select()->from(HostingModel::struct())
						->order('name')
						->fetch();
		
		$c = Config::$itemsPerMenu;
		foreach ($hostings as $hosting) {
			if($c <= 0)
			{
				--$c;
				break;
			}
			
			if(Acl::instance()->allowed('hosting:'.$hosting->name))
				$this->_children[] = new Link($hosting->name, 
					'hosting:'.$hosting->name, $this->_action, $hosting->name);
			else
				continue;
			
			--$c;
		}
		
		// Este nam ostava domena
		if($c < 0)
			$this->_children[] = 
				new Link(L::selected()->more, 'hosting:*', $this->_action);
	}
	
	public function children()
	{
		return $_children;
	}
}
